<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 5.4.2">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha256-HtsXJanqjKTc8vVQjO4YMhiqFoXkfBsjBWcX91T1jr8=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"xiaoqingming18.github.io","root":"/","images":"/images","scheme":"Muse","darkmode":false,"version":"8.15.1","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>

    <meta name="description" content="数据库依赖的公理系统Armstrong 公理Armstrong 公理规定了以下的推理规则：     推理规则 内容     A1 自反律 若 Y⊆X⊆U, 则 X→Y 成立   A2 增广律 若 Z⊆U 且 X→Y，则 XZ→YZ 成立   A3 传递律 若 X→Y，Y→Z，则 X→Z 成立     根据以上三条公理，可得到以下推理规则：     推理规则 内容     合并规则 若 X→Y，X→">
<meta property="og:type" content="article">
<meta property="og:title" content="数据库原理：求最小依赖集和候选键">
<meta property="og:url" content="http://xiaoqingming18.github.io/2023/04/24/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%8E%9F%E7%90%86%EF%BC%9A%E6%B1%82%E6%9C%80%E5%B0%8F%E4%BE%9D%E8%B5%96%E9%9B%86%E5%92%8C%E5%80%99%E9%80%89%E9%94%AE/index.html">
<meta property="og:site_name" content="鸣蜩十七">
<meta property="og:description" content="数据库依赖的公理系统Armstrong 公理Armstrong 公理规定了以下的推理规则：     推理规则 内容     A1 自反律 若 Y⊆X⊆U, 则 X→Y 成立   A2 增广律 若 Z⊆U 且 X→Y，则 XZ→YZ 成立   A3 传递律 若 X→Y，Y→Z，则 X→Z 成立     根据以上三条公理，可得到以下推理规则：     推理规则 内容     合并规则 若 X→Y，X→">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-04-23T16:57:03.000Z">
<meta property="article:modified_time" content="2023-05-11T13:48:23.248Z">
<meta property="article:author" content="鸣蜩十七">
<meta property="article:tag" content="笔记">
<meta property="article:tag" content="数据库">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="http://xiaoqingming18.github.io/2023/04/24/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%8E%9F%E7%90%86%EF%BC%9A%E6%B1%82%E6%9C%80%E5%B0%8F%E4%BE%9D%E8%B5%96%E9%9B%86%E5%92%8C%E5%80%99%E9%80%89%E9%94%AE/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://xiaoqingming18.github.io/2023/04/24/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%8E%9F%E7%90%86%EF%BC%9A%E6%B1%82%E6%9C%80%E5%B0%8F%E4%BE%9D%E8%B5%96%E9%9B%86%E5%92%8C%E5%80%99%E9%80%89%E9%94%AE/","path":"2023/04/24/数据库原理：求最小依赖集和候选键/","title":"数据库原理：求最小依赖集和候选键"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>数据库原理：求最小依赖集和候选键 | 鸣蜩十七</title>
  








  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>

<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">鸣蜩十七</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">鸣蜩十七是和女朋友谈恋爱的日子</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li><li class="menu-item menu-item-schedule"><a href="/schedule/" rel="section"><i class="fa fa-calendar fa-fw"></i>日程表</a></li><li class="menu-item menu-item-sitemap"><a href="/sitemap.xml" rel="section"><i class="fa fa-sitemap fa-fw"></i>站点地图</a></li><li class="menu-item menu-item-commonweal"><a href="/404/" rel="section"><i class="fa fa-heartbeat fa-fw"></i>公益 404</a></li>
  </ul>
</nav>




</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%95%B0%E6%8D%AE%E5%BA%93%E4%BE%9D%E8%B5%96%E7%9A%84%E5%85%AC%E7%90%86%E7%B3%BB%E7%BB%9F"><span class="nav-text">数据库依赖的公理系统</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#Armstrong-%E5%85%AC%E7%90%86"><span class="nav-text">Armstrong 公理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%87%BD%E6%95%B0%E4%BE%9D%E8%B5%96%E9%97%AD%E5%8C%85"><span class="nav-text">函数依赖闭包</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">鸣蜩十七</p>
  <div class="site-description" itemprop="description">记录我的学习、生活和恋爱日常</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">43</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">8</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">37</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://xiaoqingming18.github.io/2023/04/24/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%8E%9F%E7%90%86%EF%BC%9A%E6%B1%82%E6%9C%80%E5%B0%8F%E4%BE%9D%E8%B5%96%E9%9B%86%E5%92%8C%E5%80%99%E9%80%89%E9%94%AE/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="鸣蜩十七">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="鸣蜩十七">
      <meta itemprop="description" content="记录我的学习、生活和恋爱日常">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="数据库原理：求最小依赖集和候选键 | 鸣蜩十七">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          数据库原理：求最小依赖集和候选键
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-04-24 00:57:03" itemprop="dateCreated datePublished" datetime="2023-04-24T00:57:03+08:00">2023-04-24</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2023-05-11 21:48:23" itemprop="dateModified" datetime="2023-05-11T21:48:23+08:00">2023-05-11</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%8E%9F%E7%90%86/" itemprop="url" rel="index"><span itemprop="name">-数据库原理</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h1 id="数据库依赖的公理系统"><a href="#数据库依赖的公理系统" class="headerlink" title="数据库依赖的公理系统"></a>数据库依赖的公理系统</h1><h2 id="Armstrong-公理"><a href="#Armstrong-公理" class="headerlink" title="Armstrong 公理"></a>Armstrong 公理</h2><p><strong>Armstrong 公理</strong>规定了以下的推理规则：</p>
<div class="table-container">
<table>
<thead>
<tr>
<th>推理规则</th>
<th>内容</th>
</tr>
</thead>
<tbody>
<tr>
<td>A1 自反律</td>
<td>若 Y⊆X⊆U, 则 X→Y 成立</td>
</tr>
<tr>
<td>A2 增广律</td>
<td>若 Z⊆U 且 X→Y，则 XZ→YZ 成立</td>
</tr>
<tr>
<td>A3 传递律</td>
<td>若 X→Y，Y→Z，则 X→Z 成立</td>
</tr>
</tbody>
</table>
</div>
<p>根据以上三条公理，可得到以下推理规则：</p>
<div class="table-container">
<table>
<thead>
<tr>
<th>推理规则</th>
<th>内容</th>
</tr>
</thead>
<tbody>
<tr>
<td>合并规则</td>
<td>若 X→Y，X→Z，则 X→YZ 成立</td>
</tr>
<tr>
<td>伪传递规则</td>
<td>若 X→Y，WY→Z，则 WX→Z 成立</td>
</tr>
<tr>
<td>分解规则</td>
<td>若 X→Y，且 Z⊆Y，则 X→Z 成立</td>
</tr>
<tr>
<td>复合规则</td>
<td>若 X→Y，且 W→Z，则 XW→ZY 成立</td>
</tr>
</tbody>
</table>
</div>
<p>通过这些推导，我们可以得出关系模式R的所有函数依赖，包括直接和间接的函数依赖。这些函数依赖可以用来判断该关系模式是否符合范式的要求，以及进行范式分解和数据库设计。</p>
<h2 id="函数依赖闭包"><a href="#函数依赖闭包" class="headerlink" title="函数依赖闭包"></a>函数依赖闭包</h2><p>设F为属性集U上的一组函数依赖，X、Y⊆U，$X_F^+={A|X→A能由F根据Armstrong公理导出}$,$X_F^+$称为<strong>属性集X关于函数依赖集F的闭包</strong>。</p>
<p>说人话就是，属性或属性组X的闭包$X_F^+$就是能由X推导出的属性的集合。</p>
<p>例如设属性集 U={A,B,C}，函数依赖集 F={A→B, B→C} 则 AF+={A，B，C}，BF+={B，C}，CF+={C}。</p>
<p>大题的做法如下：</p>
<p>例如，已知关系模式R<u,f>，其中，U={A,B,C,D,E}，F={AB→C,B→D,C→E,EC→B,AC→B}。求$(AB)_F^+$。</u,f></p>
<p><strong>解</strong>    设$X^{(0)}=AB$  <strong>求谁的闭包就设$X^{(0)}$等于谁</strong><br>求$X^{(1)}：$因为AB→C，B→D，所以$X^{(1)}=X^{(0)} \cup CD=AB \cup CD=ABCD$<br><strong>这一步首先在F中找AB($X^{(0)}$)的子集，再用AB($X^{(0)}$)并上找到的函数依赖右边的属性，这就是$X^{(2)}$的值</strong><br>求$X^{(2)}：$因为C→E,AC→B，所以$X^{(2)}=X^{(1)} \cup CD=ABCD \cup BE=ABCDE=U$<br><strong>当$X^{(i+1)}=X^{(i)}$或$X^{(i+1)}=U$时停止，此时的$X^{(i+1)}$就是待求的闭包</strong><br>所以，$(AB)_F^+={ABCDE}$</p>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E7%AC%94%E8%AE%B0/" rel="tag"># 笔记</a>
              <a href="/tags/%E6%95%B0%E6%8D%AE%E5%BA%93/" rel="tag"># 数据库</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2023/04/23/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%8E%9F%E7%90%86%EF%BC%9A%E5%85%B3%E7%B3%BB%E8%A7%84%E8%8C%83%E5%8C%96/" rel="prev" title="数据库原理：关系规范化">
                  <i class="fa fa-chevron-left"></i> 数据库原理：关系规范化
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2023/04/24/%E5%AF%B9%E8%B1%A1%E3%80%81%E7%B1%BB%E4%B8%8E%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1%E7%BC%96%E7%A8%8B/" rel="next" title="对象、类与面向对象编程">
                  对象、类与面向对象编程 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">鸣蜩十七</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>
  <div class="sidebar-dimmer"></div>
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script>

  




  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>



</body>
</html>
